feat(config): exporter plugin loading via entry points for declarative config#5128
Draft
MikeGoldsmith wants to merge 2 commits intoopen-telemetry:mainfrom
Draft
feat(config): exporter plugin loading via entry points for declarative config#5128MikeGoldsmith wants to merge 2 commits intoopen-telemetry:mainfrom
MikeGoldsmith wants to merge 2 commits intoopen-telemetry:mainfrom
Conversation
SpanExporter, LogRecordExporter, and PushMetricExporter are changed from @DataClass to TypeAlias = dict[str, Any] in models.py, preserving unknown exporter names as dict keys through the config pipeline. Each signal's factory function (_create_span_exporter, _create_log_record_exporter, _create_push_metric_exporter) now has a registry of known exporter names (otlp_http, otlp_grpc, console) with fallback to load_entry_point for unknown names via the opentelemetry_{traces,logs,metrics}_exporter entry point groups. _parse_headers in _common.py is updated to handle both NameStringValuePair objects (typed config) and raw dicts (YAML path), making the full dict path testable end-to-end. Assisted-by: Claude Opus 4.6
This was referenced Apr 20, 2026
The generated models are unchanged. Python dataclasses don't enforce field types at runtime, so parent fields like BatchSpanProcessor.exporter naturally accept raw dicts (from the YAML loader) alongside typed instances. Tests updated to pass raw dicts consistently. Assisted-by: Claude Opus 4.6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extends exporter support in declarative file configuration to handle custom (plugin) exporters across all three signals, matching the spec's PluginComponentProvider mechanism.
Solution
Each signal's factory function now has an exporter registry:
_SPAN_EXPORTER_REGISTRYopentelemetry_traces_exporter_METRIC_EXPORTER_REGISTRYopentelemetry_metrics_exporter_LOG_EXPORTER_REGISTRYopentelemetry_logs_exporterKnown names (
otlp_http,otlp_grpc,console) route to existing typed factory functions. Unknown names fall back toload_entry_point().The generated models are unchanged. Python dataclasses don't enforce field types at runtime, so parent fields like
BatchSpanProcessor.exporternaturally accept raw dicts (from the YAML loader) alongside typed instances. This preserves unknown plugin names as dict keys without diverging from codegen._parse_headersin_common.pyis also updated to handle bothNameStringValuePairobjects (typed config path) and raw dicts (YAML path), making the full dict path testable.Custom exporter example
Remaining work
The OTLP factory functions still use typed attribute access (
config.endpoint, etc.) internally. Converting them to accept raw dicts from the YAML loader is tracked in #5127.Closes #5069